package com.chanyachting.emall.form;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.upload.FormFile;

import com.chanyachting.emall.domain.Company;
import com.chanyachting.emall.domain.Sellyacht;
import com.chanyachting.emall.util.RequestUtil;

public class CompanyProductForm extends ActionForm {
	
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -3687907771542739045L;

	// primary key
	private java.lang.Integer id;

	// fields
	//private java.lang.String refreshDate;
	private java.lang.Integer companyId;
	private java.lang.String summary;
	private java.lang.Integer channelId;
	private java.lang.String type;  //商品类型 （普通，销售，租赁 。。。）
	private java.lang.String title;
	//private java.lang.String status;
	private java.lang.Integer brandId;
	//private java.lang.String updateDate;
	
	//private java.lang.Integer productCategoryId;
	//private java.lang.String createDate;
	private java.lang.String name;
	private java.lang.Integer point;
	private java.lang.String productdesc;
	
	
	
	private int currentPage;
	private int pageSize;
	private java.lang.String pageType;
	private int pageCount;
	
	private String optype; //用户操作类型 (发布推荐，发布展示，待上架)
	
	private FormFile file;
	
	private FormFile pimg1;  //产品图片1
	private FormFile pimg2;  //产品图片2
	private FormFile pimg3;
	private FormFile pimg4;
	private FormFile pimg5; //产品图片5
	
	private String imgdesc1; //产品图片1描述内容
	private String imgdesc2; //产品图片2描述内容
	private String imgdesc3; //产品图片3描述内容
	private String imgdesc4; //产品图片4描述内容
	private String imgdesc5; //产品图片5描述内容
	
	
	private Company comp;
	
	private List<Sellyacht> cpList = new ArrayList<Sellyacht>();
	
	
	
	@Override
	public ActionErrors validate(ActionMapping mapping,
			HttpServletRequest request) {
		
		ActionErrors errors=new ActionErrors();
		
		RequestUtil ru=new RequestUtil(request);
		
		Map params = request.getParameterMap();
		Iterator iter = params.entrySet().iterator();
		while (iter.hasNext()) {
			Map.Entry entry  = (Map.Entry)iter.next();
			String key = entry.getKey().toString();
			
			
			String val[] = (String[]) entry.getValue();
			System.out.println("key=" + key + " ;value=" + val[0]);
		}
		
		Integer tmpInt = 0;
		if(tmpInt.equals(this.getCompanyId())){
			
			errors.add("",new ActionMessage(""));

			ru.setMsg("所属公司不能为空！");
			System.out.println("aaaaa所属公司不能为空！");
			
		} else {
			return null;
		}
		
		if(this.getName()==null || this.getName().trim().equals("")){
			
			errors.add("",new ActionMessage(""));
			
			ru.setMsg("商品名称不能为空！");
			System.out.println("bbbb商品名称不能为空！");
		}
		
		return errors;
	}
	
	
	
	
	
	public String getImgdesc1() {
		return imgdesc1;
	}





	public void setImgdesc1(String imgdesc1) {
		this.imgdesc1 = imgdesc1;
	}





	public String getImgdesc2() {
		return imgdesc2;
	}





	public void setImgdesc2(String imgdesc2) {
		this.imgdesc2 = imgdesc2;
	}





	public String getImgdesc3() {
		return imgdesc3;
	}





	public void setImgdesc3(String imgdesc3) {
		this.imgdesc3 = imgdesc3;
	}





	public String getImgdesc4() {
		return imgdesc4;
	}





	public void setImgdesc4(String imgdesc4) {
		this.imgdesc4 = imgdesc4;
	}





	public String getImgdesc5() {
		return imgdesc5;
	}





	public void setImgdesc5(String imgdesc5) {
		this.imgdesc5 = imgdesc5;
	}





	public FormFile getPimg1() {
		return pimg1;
	}



	public void setPimg1(FormFile pimg1) {
		this.pimg1 = pimg1;
	}



	public FormFile getPimg2() {
		return pimg2;
	}



	public void setPimg2(FormFile pimg2) {
		this.pimg2 = pimg2;
	}



	public FormFile getPimg3() {
		return pimg3;
	}



	public void setPimg3(FormFile pimg3) {
		this.pimg3 = pimg3;
	}



	public FormFile getPimg4() {
		return pimg4;
	}



	public void setPimg4(FormFile pimg4) {
		this.pimg4 = pimg4;
	}



	public FormFile getPimg5() {
		return pimg5;
	}



	public void setPimg5(FormFile pimg5) {
		this.pimg5 = pimg5;
	}



	public String getOptype() {
		return optype;
	}
	public void setOptype(String optype) {
		this.optype = optype;
	}
	
	public FormFile getFile() {
		return file;
	}
	public void setFile(FormFile file) {
		this.file = file;
	}
	
	
	
	public List<Sellyacht> getCpList() {
		return cpList;
	}
	public void setCpList(List<Sellyacht> cpList) {
		this.cpList = cpList;
	}
	
	
	public int getCurrentPage() {
		return currentPage;
	}
	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}
	public int getPageSize() {
		return pageSize;
	}
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}
	public java.lang.String getPageType() {
		return pageType;
	}
	public void setPageType(java.lang.String pageType) {
		this.pageType = pageType;
	}
	public int getPageCount() {
		return pageCount;
	}
	public void setPageCount(int pageCount) {
		this.pageCount = pageCount;
	}

	public Company getComp() {
		return comp;
	}
	public void setComp(Company comp) {
		this.comp = comp;
	}
	public java.lang.String getSummary() {
		return summary;
	}
	public void setSummary(java.lang.String summary) {
		this.summary = summary;
	}
	public java.lang.Integer getChannelId() {
		return channelId;
	}
	public void setChannelId(java.lang.Integer channelId) {
		this.channelId = channelId;
	}
	public java.lang.String getType() {
		return type;
	}
	public void setType(java.lang.String type) {
		this.type = type;
	}
	public java.lang.String getTitle() {
		return title;
	}
	public void setTitle(java.lang.String title) {
		this.title = title;
	}
	public java.lang.Integer getBrandId() {
		return brandId;
	}
	public void setBrandId(java.lang.Integer brandId) {
		this.brandId = brandId;
	}

	
	public java.lang.Integer getId() {
		return id;
	}
	public void setId(java.lang.Integer id) {
		this.id = id;
	}
	public java.lang.String getProductdesc() {
		return productdesc;
	}
	public void setProductdesc(java.lang.String productdesc) {
		this.productdesc = productdesc;
	}
	
	public java.lang.Integer getCompanyId() {
		return companyId;
	}
	public void setCompanyId(java.lang.Integer companyId) {
		this.companyId = companyId;
	}
	
	
	
	public java.lang.Integer getPoint() {
		return point;
	}
	public void setPoint(java.lang.Integer point) {
		this.point = point;
	}
	public java.lang.String getName() {
		return name;
	}
	public void setName(java.lang.String name) {
		this.name = name;
	}
	
	
	
	

}
